Repository navigation
Fix rendering of HTML enumerated boolean attributes (draggable, spellcheck, contenteditable) - #67970
BrundhaVelusamy wants to merge 34 commits into
Conversation
|
Thanks for your PR, @BrundhaVelusamy. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
…my/aspnetcore into DraggableAttribute
There was a problem hiding this comment.
Pull request overview
This PR updates Blazor’s element-attribute rendering so that certain HTML enumerated attributes supplied as bool are emitted with explicit "true"/"false" string values (instead of presence/absence), ensuring spec-compliant HTML and more consistent browser behavior for drag-and-drop and related features.
Changes:
- Update
RenderTreeBuilderto render enumerated bool attributes with explicit"true"/"false"string values for elements (while preserving boxedboolbehavior for component parameters). - Add
RenderTreeBuilderunit tests covering enumerated attributes (including case-insensitive matching) and confirming regular boolean attributes remain unchanged. - Add an
HtmlRenderertest validating the serialized HTML output fordraggablewhen supplied asbool.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Components/Components/src/Rendering/RenderTreeBuilder.cs | Adds enumerated-attribute handling so element attributes like draggable render ="true"/"false" rather than presence/absence. |
| src/Components/Components/test/Rendering/RenderTreeBuilderTest.cs | Adds tests verifying frames for enumerated attributes use explicit string values and that component parameters remain boxed bools. |
| src/Components/Web/test/HtmlRendering/HtmlRendererTest.cs | Adds rendering test asserting HTML output includes draggable="true" / draggable="false". |
Suppressed comments (1)
src/Components/Components/src/Rendering/RenderTreeBuilder.cs:386
- The XML doc comment says a boxed false boolean value for an element attribute will be omitted, but enumerated bool attributes now render an explicit "false" value. Please update the doc comment to reflect the enumerated-attribute exception.
else if (value is bool boolValue)
{
if (IsEnumeratedBoolAttribute(name))
{
_entries.AppendAttribute(sequence, name, boolValue ? "true" : "false");
}
else if (boolValue)
…my/aspnetcore into DraggableAttribute
|
/review |
There was a problem hiding this comment.
🟡 Changes recommended
Valueless draggable attributes are still stored as boxed true, causing serializer round-trips to change their rendered value on interactive activation without any application state change.
1 open issue
2 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
Source-only review of frozen head c98584e45d29ce7f68fcfb3afc48fd5207b3a682 (merge base 9ea8a84d9c7c1a63256d2256969d5a6c66103d83, base tip and trusted guidance commit 18781e9d03cba0f3df9cdf7fae90f77771ca9f00).
Two source-reachable candidates remain unresolved because the frozen evidence does not include the binding contracts needed to determine whether the valueless overload and writingsuggestions belong within this change. Both are identified inline rather than asserted as verified defects.
Existing-feedback coverage: the missing real-browser regression boundary is already covered by inline thread 4358157919; deduplication is neutral and does not imply that concern is settled. The current unit test exercises the typed Boolean overload only, while the assigned Components guidance requires real-browser coverage for browser-owned user-visible behavior. Feedback posted after bundle preparation is not observable here.
Guide completion:
docs/CrossCuttingGuidance.md: complete for source-reviewable change shape, API/docs, correctness, producer/consumer paths, performance, compatibility, and changed-test fidelity.docs/BlazorComponentsGuidance.md: complete for rendering, overload compatibility, static/interactive consumption, documentation, and regression-test fidelity.- Both workers used the required
review-guide-workerprofile and explicitgpt-5.6-solmodel; reasoning effort was not supplied (runtime default). The post-gate candidates were independently checked by onereview-candidate-verifieron the same model.
Uncovered areas: none among materially changed files; routed cross-cutting and Blazor Components guidance covered the change. Runtime, browser, CI, and sample execution were excluded by the supplied source-only policy, and security assessment was excluded by repository review policy. No target code was executed; red/green and browser behavior remain unverified. Proof is limited to tracked frozen Git bytes; symlink, submodule, LFS target behavior, external HTML contracts, and post-preparation feedback are unavailable.
Generated by ASP.NET Core Pull Request Review for #67970 · copilot · gpt56 · 219.3 AIC · ⌖ 8.77 AIC · ⊞ 20.1K
Comment /review to run again
|
Copilot's local review panel found no issues to raise at this commit. All three local arms completed at Informational discarded checks: The explicit Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block Untested coverage gaps: The changed object/splat path, the other two attribute names, case matching, and browser rendering/update scenarios were not exercised. The existing browser-regression discussion remains in thread 4358157919; it is not being reposted as a new finding. Validation boundary: all three arms used frozen-source analysis; no target build, tests, or browser validation was run. Human-directed and GitHub Copilot-generated. |
|
/review |
There was a problem hiding this comment.
🟡 Changes recommended
Required real-browser coverage is missing for the four enumerated attributes, including initial rendering and true → false → true updates on Server and WebAssembly.
1 open issue
1 resolved since last review
Review effort: Balanced
|
The local review panel completed at Informational discarded/unresolved diagnostics: One arm questioned whether the updated The explicit true/false presence and inheritance changes match the documented PR intent. Routine discarded checks established no additional defect in component Boolean preservation, splatting, duplicate precedence, repeated updates, downstream string handling, or newly produced fragment replay. No material lookup-cost/shared-set issue, supported raw-event-update failure, ARIA scope obligation, or cross-version fragment contract was established. Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block Untested coverage gaps: The arms did not execute target rendering or browser scenarios. Static output, interactive initial rendering and updates, splatting, the remaining attribute-name/casing cases, and browser properties remain without new runtime evidence from this panel. The existing browser-coverage thread above is not being reposted as a new finding. Validation boundary: G and S used frozen-source analysis; O additionally ran a scratch Razor code-generation probe, not PR code. No target build, tests, or browser validation ran. Human-directed and GitHub Copilot-generated. |
@PureWeen, Thanks for the follow-up. I’ve addressed the open browser-coverage thread with one shared Selenium test that runs on both Blazor Server and WebAssembly. The test checks the DOM attributes and corresponding browser properties for Both renderer cases failed at the initial |
|
/review |
|
Copilot's local review panel found no issues to raise at this commit. All three local arms completed at Informational diagnostic: One arm revisited the valueless Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block Untested coverage gaps: This panel did not independently execute the target build, tests, or browser cases, including browser-version support for Validation boundary: all three arms and both independent double-checks used frozen-source evidence; no target runtime or browser validation was run. The current-head hosted Human-directed and GitHub Copilot-generated. |
|
Thank you for the contribution. Blazor maps a |


Description
This change updates Blazor's attribute rendering behavior for HTML enumerated boolean attributes so that they are rendered with explicit string values ("true" / "false") instead of using the standard boolean attribute presence/absence pattern.
Blazor currently treats all bool attributes as HTML boolean attributes:
This behavior is correct for attributes such as disabled, checked, and readonly, but it does not match the semantics of HTML enumerated attributes like:
These attributes expect explicit "true" or "false" values and may not behave consistently when rendered as presence/absence attributes.
Changes
Special handling has been added for the following enumerated attributes:
Examples:
Before:
After:
And:
Output
Before:
DraggableAttr_Issue.mp4
After:
DraggableAttr_Fix.mp4
Fixes #60137
While the issue was originally reported for draggable, the implementation applies the same behavior to other HTML enumerated attributes that share the same "true"/"false" value semantics to ensure consistent rendering behavior.